﻿@using GoodMan.Infrastructure.Entities.Entity;
@using GoodMan.Infrastructure.Entities.Enum;
@using GoodMan.Portal.Biz;
@if (HttpContext.Current.User.Identity.IsAuthenticated)
{
    var user = new User().Find(HttpContext.Current.User.Identity.Name);
    if (user != null && user.SystemRole == UserRole.Staff)
    {
        var dId = SupportBiz.IsOnDuty(HttpContext.Current.User.Identity.Name);

        if (dId != -999)
        {
    <link type="text/css" rel="Stylesheet" href="/Content/css/jquery.gritter.css" />
    <script type="text/javascript" src="/Scripts/jquery.gritter.min.js"></script> 
    <script type="text/javascript">
        //设置暂离
        function setleave(sender) {
            $('#btnstate').removeClass('btn-success').addClass('btn-warning').html('暂离 <span class="caret"></span>');
            $.ajax({
                url: '/home/setOnlineState?state=2',
                cache: false
            });
        }
        //设置在线
        function setonline(sender) {
            $('#btnstate').removeClass('btn-warning').addClass('btn-success').html('在线 <span class="caret"></span>');
            $.ajax({
                url: '/home/setOnlineState?state=1',
                cache: false
            });
        }
    </script>
        }
    <script type="text/javascript">
        $(function () {
            window.setInterval(function () {
                $.ajax({
                    url: '/home/refresh',
                    cache: false,
                    success: function (data) {
                        if (data != '') {
                            var message = eval('(' + data + ')');
                            if (message) {
                                for (var i = 0, len = message.length; i < len; i++) {
                                    $.gritter.add({
                                        title: '您有一条新订单需要处理!',
                                        text: '<a href="/workspace/staff/waitforhandleorder">' + message[i].Message + '</a>',
                                        sticky: true,
                                        time: '',
                                        class_name: 'my-sticky-class'
                                    });
                                }
                            }
                        }
                    }
                });
            }, 10000);
        });
    </script>
    }
}